package com.shuqi.model.parse.parser;

import org.xml.sax.Attributes;
import org.xml.sax.SAXException;

import com.shuqi.model.bean.ChapterInfo;
import com.shuqi.model.parse.HandlerBase;

/**
 * 购买章节解析
 * 
 * @author zhangpeng
 * 
 */
public class BuyChapterParser extends HandlerBase {

    private ChapterInfo info;

    @Override
    public void startDocument() throws SAXException {
        info = new ChapterInfo();
        super.startDocument();
    }

    @Override
    public void startElement(String uri, String localName, String qName, Attributes attrs)
            throws SAXException {
        if ("ChapterInfo".equals(localName)) {
            info.setBookId(isNull(attrs, "bookId"));
            info.setCurChapterCid(isNull(attrs, "chapterId"));
            info.setCurChapterType(isNull(attrs, "code"));
            info.setIsUpdateCatalog(isNull(attrs, "update") );
            info.setCurChapterPrice(isNull(attrs, "price") );
            info.setMsg(isNull(attrs, "msg"));
        }
        super.startElement(uri, localName, qName, attrs);
    }

    @Override
    public Object getParsedData() {
        // TODO Auto-generated method stub
        return info;
    }

}
